<div class="modal fade" tabindex="-1" id="address_form_modal">
  <div class="modal-dialog modal-md">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
        <h2 class="modal-title" id="myModalLabel">收货地址</h2>
      </div>
      <%= form_for @address, url: (@address.new_record? ? addresses_path : address_path(@address)), method: (@address.new_record? ? :post : :put), remote: true, html: { class: "form-horizontal address-form" } do |f|  %>
        <div class="modal-body">
          <% unless @address.errors.blank? %>
            <div class="alert alert-danger">
              <ul>
                <% @address.errors.messages.values.flatten.each do |error| %>
                  <li><%= error %></li>
                <% end -%>
              </ul>
            </div>
          <% end %>
          <div class="form-group">
            <label for="address" class="col-sm-2 control-label">详细地址:*</label>
            <div class="col-sm-7">
              <%= f.text_area :address, class: "form-control" %>
            </div>
            <div class="col-sm-2 address_input_error">
            </div>
          </div>
          <div class="form-group">
            <label for="contact_name" class="col-sm-2 control-label">姓名:*</label>
            <div class="col-sm-7">
              <%= f.text_field :contact_name, class: "form-control" %>
            </div>
            <div class="col-sm-2 address_input_error">
            </div>
          </div>
          <div class="form-group">
            <label for="cellphone" class="col-sm-2 control-label">手机号码:*</label>
            <div class="col-sm-7">
              <%= f.text_field :cellphone, class: "form-control" %>
            </div>
            <div class="col-sm-2 address_input_error">
            </div>
          </div>
          <div class="form-group">
            <label for="zipcode" class="col-sm-2 control-label">邮政编码:</label>
            <div class="col-sm-7">
              <%= f.text_field :zipcode, class: "form-control" %>
            </div>
            <div class="col-sm-2 address_input_error">
            </div>
          </div>
          <div class="form-group">
            <div class="col-sm-offset-2 col-sm-10">
              <label>
                <input type="checkbox" name="address[set_as_default]" <%= 'checked' if current_user.default_address == @address %> value="1" /> 设为默认地址
              </label>
            </div>
          </div>
        </div>
        <div class="modal-footer">
          <!-- <button type="button" class="btn btn-default" data-dismiss="modal">Close</button> -->
          <span class="address_form_progress"></span>
          <%= f.submit "保存", class: "btn btn-primary" %>
        </div>
      <% end -%>
    </div>
  </div>
</div>
